package com.msg.chestionar.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.msg.chestionar.to.RaspunsuriTO;

@NamedQueries( {
		@NamedQuery(name = "RaspunsuriE.findById", query = "SELECT u FROM RaspunsuriE u WHERE u.id = :id"),
		@NamedQuery(name = "RaspunsuriE.findAll", query = "SELECT u FROM RaspunsuriE u"),
		@NamedQuery(name = "RaspunsuriE.getRaspText", query = "SELECT r FROM RaspunsuriE r WHERE r.intrebare_id = :id and r.optiune_id is null"),
		@NamedQuery(name = "RaspunsuriE.getRaspByOptiune", query = "SELECT r FROM RaspunsuriE r WHERE r.optiune_id = :id"),
		@NamedQuery(name = "RaspunsuriE.getRaspByIntrebare", query = "SELECT r FROM RaspunsuriE r WHERE r.intrebare_id = :id"),
		@NamedQuery(name = "RaspunsuriE.getRaspByChestionar", query = "SELECT r FROM RaspunsuriE r WHERE r.chestionar_id = :id"),
		@NamedQuery(name = "RaspunsuriE.getRaspByUser", query = "SELECT r FROM RaspunsuriE r WHERE r.user_id = :id") })
@Entity
@Table(name = "T_RASPUNSURI")
@SequenceGenerator(name = "SEQ_RASPUNSURI", sequenceName = "SEQ_RASPUNSURI", allocationSize = 1)
public class RaspunsuriE {

	// si apoi voi face metoda getRaspunsuriTO

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_RASPUNSURI")
	private Long id;

	@Column
	private Long chestionar_id;

	@Column
	private Long intrebare_id;

	@Column
	private Long optiune_id;

	@Column
	private Long user_id;

	@Column
	private String comentariu;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getChestionar_id() {
		return chestionar_id;
	}

	public void setChestionar_id(Long chestionarId) {
		chestionar_id = chestionarId;
	}

	public Long getIntrebare_id() {
		return intrebare_id;
	}

	public void setIntrebare_id(Long intrebareId) {
		intrebare_id = intrebareId;
	}

	public Long getOptiune_id() {
		return optiune_id;
	}

	public void setOptiune_id(Long optiuneId) {
		optiune_id = optiuneId;
	}

	public Long getUser_id() {
		return user_id;
	}

	public void setUser_id(Long userId) {
		user_id = userId;
	}

	public String getComentariu() {
		return comentariu;
	}

	public void setComentariu(String comentariu) {
		this.comentariu = comentariu;
	}

	public RaspunsuriTO getRaspunsTO() {

		RaspunsuriTO raspunsTO = new RaspunsuriTO();
		raspunsTO.setChestionar_id(this.chestionar_id);
		raspunsTO.setId(this.id);
		raspunsTO.setIntrebare_id(this.intrebare_id);
		raspunsTO.setOptiune_id(this.optiune_id);
		raspunsTO.setUser_id(user_id);
		raspunsTO.setComentariu(comentariu);

		return raspunsTO;

	}

}
